package com.hmy.finance.service.receipt.dto;

import cn.hutool.core.bean.BeanUtil;
import com.hmy.ccp.common.dto.ContextUserInfo;
import com.hmy.ccp.starter.web.utils.UserContextUtil;
import com.hmy.finance.api.bo.core.request.enums.ReceiptOffsetBillStatusEnum;
import com.hmy.finance.api.bo.core.request.receiptOffset.ReceiptOffsetCancelRequest;
import com.hmy.finance.dal.po.receipt.ReceiptOffsetBillPo;
import java.io.Serializable;
import java.util.Map;
import lombok.Data;

@Data
public class ReceiptOffsetCancelDto implements Serializable {

    private final ReceiptOffsetBillStatusEnum targetStatus = ReceiptOffsetBillStatusEnum.CANCEL;

    /**
     * 核销单id
     */
    private Long receiptOffsetBillId;

    /**
     * 作废备注
     */
    private String comment;

    /**
     * 核销单
     */
    private ReceiptOffsetBillPo receiptOffsetBillPo;
    
    public static ReceiptOffsetCancelDto convertToDto(ReceiptOffsetCancelRequest request){
        return BeanUtil.copyProperties(request, ReceiptOffsetCancelDto.class);
    }

    public Map<String, Object> buildCancelProcessRequest() {
        ReceiptOffsetBillProcessVariableDto variableDto = BeanUtil.copyProperties(receiptOffsetBillPo, ReceiptOffsetBillProcessVariableDto.class);
        ContextUserInfo userInfo = UserContextUtil.getCurrentUser();
        variableDto.setUpdaterId(userInfo.getId());
        variableDto.setUpdaterName(userInfo.getUserName());
        variableDto.buildReceiptOffsetBillStatus(targetStatus);
        return BeanUtil.beanToMap(variableDto);
    }
    
}
